package cn.peach.hrm.controller;

import cn.peach.hrm.doc.CourseDoc;
import cn.peach.hrm.dto.CourseSearchDto;
import cn.peach.hrm.service.ICourseESService;
import cn.peach.hrm.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author you
 * @create 2021/11/28 16:09
 */
@RestController
@RequestMapping("/course")
public class CourseESController {

    @Autowired
    private ICourseESService courseESService;

    /**
     * 保存课程
     * @param courseDoc
     * @return
     */
    @RequestMapping("/save")
    public AjaxResult save(@RequestBody CourseDoc courseDoc){
        courseESService.save(courseDoc);
        return AjaxResult.me();
    }

    /**
     * 搜索课程
     * @param dto
     * @return
     */
    @PostMapping("/search")
    public AjaxResult search(@RequestBody CourseSearchDto dto){
        return AjaxResult.me().setResultObj(courseESService.search(dto));
    }
}
